package com.example.event;

import cn.hutool.core.lang.UUID;
import com.example.dto.OrderCreateDTO;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

import static com.example.constant.MqConstants.Exchange.ORDER_EXCHANGE;
import static com.example.constant.MqConstants.Key.ORDER_DELAY_KEY;

@Component
public class OrderCloseEvent extends BaseEvent<List<OrderCreateDTO>>{
    private String topic = ORDER_EXCHANGE;

    private String routingKey = ORDER_DELAY_KEY;
    @Override
    public EventMessage<List<OrderCreateDTO>> buildEventMessage(List<OrderCreateDTO> data) {
        return EventMessage.<List<OrderCreateDTO>>builder()
                .data(data)
                .id(UUID.randomUUID().toString())
                .timestamp(new Date())
                .build();
    }


    @Override
    public String topic() {
        return topic;
    }

    @Override
    public String routingKey() {
        return  routingKey;
    }
}
